package com.Akronmcp.hopMessage;

import java.util.ArrayList;
import java.util.List;

import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerJoinEvent;

/**监听器类*/
public class HmListener implements Listener{
	
	
	public static List<HopMess> LJoinhml = new ArrayList<HopMess>();
	public static List<HopMess> LWorldhml = new ArrayList<HopMess>();
	public static List<HopMess> LDeathhml = new ArrayList<HopMess>();
    //监听后发送的公告
	
	/**监听玩家进服务器*/
	@EventHandler
	public void joinL(PlayerJoinEvent evt)
	{
		
		if(LJoinhml.isEmpty())
		return;
		
			
		Player p = evt.getPlayer();
		for(HopMess hm:LJoinhml)
		{//遍历公告,发送!
			hm.send(p); 
		}
		
		
	}

	/**监听玩家切换世界*/
	@EventHandler
	public void worldL(PlayerChangedWorldEvent evt)
	{
		if(LWorldhml.isEmpty())
		return;
		
		Player p = evt.getPlayer();
		for(HopMess hm:LWorldhml)
		{
			hm.send(p); 
		}
		
	}
	
	
	/**监听玩家死亡*/
	@EventHandler
	public void dieL(PlayerDeathEvent evt)
	{
		if(LDeathhml.isEmpty())
		return;
			
		Player p = evt.getEntity();
		for(HopMess hm:LDeathhml)
		{
			hm.send(p); 
		}
		
	}
}
